﻿from threading import Lock


class SimpleSyncSet:
  def __init__(self, iterable=[]):
    self.lock = Lock()
    self.lock.acquire()
    self.set = set(iterable)
    self.lock.release()

  def __len__(self):
    self.lock.acquire()
    length = len(self.set)
    self.lock.release()
    return length

  def add(self, item):
    self.lock.acquire()
    self.set.add(item)
    self.lock.release()

  def discard(self, item):
    self.lock.acquire()
    self.set.discard(item)
    self.lock.release()

  def __contains__(self, item):
    self.lock.acquire()
    res = item in self.set
    self.lock.release()
    return res
